<?php 
include("common/conn.php"); 
if($_SESSION['userid']==""){
  echo "<script>window.location.href='login.php';</script>";
}
// 查询服务中心信息
$query = mysql_query("select htfanquan,kgfanquan from xitong where id=1");
$fanquan = mysql_fetch_assoc($query);

$htfanquan = (float)$fanquan[htfanquan]*100;
$kgfanquan = (float)$fanquan[kgfanquan]*100;

// 查询服务中心信息 end

// 更新服务中心信息
if ($_POST) {
  $htfanquan = $_POST[htfanquan]/100;
  $kgfanquan = $_POST[kgfanquan]/100;
  $query = mysql_query("UPDATE xitong SET htfanquan='".$htfanquan."',kgfanquan='".$kgfanquan."' where id=1");
  echo "<script>alert('修改平台返券成功!');window.location.href='fanquan.php'</script>";
}
// 更新服务中心信息 end

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <title>e网批发管理后台</title>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <link href="css/styles.css" rel="stylesheet" type="text/css" />
  <link href="css/style2.css" rel="stylesheet" type="text/css" />
</head>

<body>

  <!--header-->
  <?php include("common/header.php");?>
  <!--header end-->


  <!-- staqrt subnav -->
  <div id="sub_nav">

    <div id="subnav_wrap" class="container_12">
      <div id="subnav" class=" grid_12">
        <ul>
          <li><a href="xitong.php">热门搜索</a></li>
          <li><a href="xieyi.php">用户协议</a></li>
          <li><a href="service.php">服务中心信息</a></li>
          <li><a href="freightRisk.php">海淘运费险</a></li>
          <li><a href="fanquan.php" class="sub_nav_active">平台返券</a></li>
          <li><a href="erweima.php">二维码</a></li>
        </ul>

      </div>

    </div>


  </div>
  <div class="container_12">
    <form action="" method="post" class="form" enctype="multipart/form-data"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="30%" scope="col"><label>海淘返券</label></td>
          <td width="50%" scope="col">
            <input name="htfanquan" type="text" class="text fanquan"  value="<?php echo $htfanquan;?>"/><label>%</label>
          </td>
        </tr>
        <tr>
          <td width="30%" scope="col"><label>快购返券</label></td>
          <td width="50%" scope="col">
            <input name="kgfanquan" type="text" class="text fanquan"  value="<?php echo $kgfanquan;?>"/><label>%</label>
          </td>
        </tr>
        <tr>
          <td width="40%" scope="col"></td>
          <td width="50%" scope="col">
            <input name="" type="button" value="提交" class="submit" />
          </td>
        </tr>
        </table>

      </form>
    </div>
</body>
<script type="text/javascript">
  // 验证固定电话
  function checkFloat(Float) {
    if (!(/^(\d*\.)?\d+$/.test(Float))) {
      return false;
    } else {
      return true;
    }
  }
  // 验证固定电话 end
  $('input[type="button"]').click(function(){
    var fanquan = $('.fanquan');
    var flag = true;
    fanquan.each(function(){
      if (!checkFloat($(this).val())) {
        flag = false;
      }
    })
    if (!flag) {
      alert('返券百分比有误');
    }else{
      $('.form').submit();
    }
  })
</script>
</html>
